{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# 1. Introduction to Robots"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 1.1 Introduction to Agent-Based Modeling"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
"CS371: Cognitive Science
\n",
"Bryn Mawr College
\n",
"Doug Blank
\n",
""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 1.2 Ladybug Robot Simulation"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Our first simulation is a discrete simulation: the world is divided into discrete locations (called patches) and the world operates in discrete time steps.\n",
"\n",
"A Ladybug world looks like this:\n",
"\n",
"\n",
"\n",
"You will be writing a brain for the Ladybug, the black and red circle in the middle of the world. In the above image, ladybug is facing up. Ladybug can:\n",
"\n",
"* turn left or right, but only in a grid-like manner\n",
"* go forward or backward specific distances\n",
"* sense the world immediately in front of it, and in its peripheral view"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 1.3 Writing a Brain"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Brains for the Ladybug Simulation are composed of a set of rules. You can have as many rules as you wish.\n",
"\n",
"Rules are composed of the following parts, separated by spaces:\n",
"\n",
"```python\n",
"STATE SENSE-PATTERN -> ACTION NEXT-STATE\n",
"```"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In your brain, you can also have comments (lines that start with a #) and blank lines. Here is a very simple brain:\n",
"\n",
"```python\n",
"# This is my first brain!\n",
"\n",
"0 ***** -> forward(1) 0\n",
"```"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Next, let's examine each part of a rule to find out what this does."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 1.3.1 STATE and NEXT-STATE"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"State is a name used as a simple memory for your ladybug. Ladybugs always start out in state \"0\". States can be any name with no spaces."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 1.3.2 SENSE-PATTERN"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Ladybugs can see in the 5 cells near the front of its head. In the following pictures, the ladybug can see the patches with a yellow circle in the, and cannot see the patches that are just green.\n",
"\n",
"Facing up:\n",
"\n",
"||| \n",
"-|-|-\n",
"||\n",
"| | \n",
"\n",
"Facing right:\n",
"\n",
"||| \n",
"-|-|-\n",
"||\n",
"||\n",
"\n",
"Facing down:\n",
"\n",
"||| \n",
"-|-|-\n",
"||\n",
"||\n",
"\n",
"Facing left:\n",
"\n",
"||| \n",
"-|-|-\n",
"||\n",
"||\n",
"\n",
"In the simulator, the ladybug is a bit bigger than its nearby cells, so it overlaps just a little, as you can see here:\n",
"\n",
"\n",
"\n",
"The 5 sense locations are matched in the same locations ego-centrally located to the ladybug. So they are always listed in this order:\n",
"\n",
"
\n", "left side\n", " | \n", "\n", "in front/left\n", " | \n", "\n", "center/forward\n", " | \n", "\n", "in front/right\n", " | \n", "\n", "right side\n", " | \n", "